package com.exchange.Controller;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings.System;
import com.exchange.Public.ExchangeConstants;
import com.exchange.Public.h;
import com.exchange.Public.n;
import com.exchange.Public.o;
import com.exchange.b.a;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class ExchangeDataService
{
  private static final int b = 0;
  private static final int c = 1;
  private static final String e = "EXCHANGE_PRELOAD_ADS";
  private static final String f = "PAGE_1";
  private static final String g = "PRELOAD";
  private String a;
  public int autofill = 1;
  private String d;
  public int displayStyle = 0;
  public Context mContext;
  public ExchangeDataRequestListener mDataReceiverListener;
  public int page_index;
  public boolean pagination;
  public int require_desc = 1;

  public ExchangeDataService()
  {
    this.a = "";
    this.pagination = false;
    this.page_index = -1;
    this.mDataReceiverListener = null;
  }

  private ArrayList<com.exchange.b.a> a(JSONObject paramJSONObject)
  {
    int i;
    JSONArray localJSONArray;
    int j;
    ArrayList localArrayList = new ArrayList();
    if (paramJSONObject == null)
    {
      n.b(ExchangeConstants.LOG_TAG, "failed requesting");
      return localArrayList;
    }
    try
    {
      do
      {
        if (!("1".equals(paramJSONObject.getString("status"))))
          break label251;
        localJSONArray = paramJSONObject.getJSONArray("promoters");
        j = 0;
        if (j < localJSONArray.length())
          break label227;
        if (paramJSONObject.has("filter"))
        {
          if (!(paramJSONObject.getString("filter").equals("1")))
            break label269;
          i = 1;
          ExchangeConstants.filterInstalledApp = i;
        }
        if (paramJSONObject.has("show_size"))
        {
          String str = paramJSONObject.getString("show_size");
          if (str != null)
          {
            if (!("1".equals(str)))
              break label262;
            ExchangeConstants.show_size = true;
          }
        }
        if (paramJSONObject.has("sid"))
          ExchangeConstants.sid = paramJSONObject.getString("sid");
        if (paramJSONObject.has("interval"))
          ExchangeConstants.REFRESH_INTERVAL = 1000 * paramJSONObject.getInt("interval");
      }
      while (!(paramJSONObject.has("preload")));
      SharedPreferences.Editor localEditor = this.mContext.getSharedPreferences(this.d, 0).edit();
      localEditor.putInt("PRELOAD", paramJSONObject.getInt("preload"));
      label262: label269: label227: label251: localEditor.commit();
    }
    catch (JSONException localJSONException)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              while (true)
                localJSONException.printStackTrace();
              localArrayList.add(com.exchange.b.a.a((JSONObject)localJSONArray.get(j)));
              ++j;
            }
            n.b(ExchangeConstants.LOG_TAG, "failed requesting");
          }
          ExchangeConstants.show_size = false;
        }
        i = 0;
      }
    }
  }

  private JSONObject a()
  {
    JSONObject localJSONObject = new JSONObject();
    try
    {
      localJSONObject.put("source", "exchange");
      localJSONObject.put("sdk_version", ExchangeConstants.sdk_version);
      localJSONObject.put("protocol_version", ExchangeConstants.protocol_version);
      localJSONObject.put("app_key", h.f(this.mContext));
      localJSONObject.put("device_id", h.i(this.mContext));
      localJSONObject.put("device_model", Build.MODEL);
      localJSONObject.put("app_version", h.g(this.mContext));
      localJSONObject.put("os", "android");
      Configuration localConfiguration = new Configuration();
      Settings.System.getConfiguration(this.mContext.getContentResolver(), localConfiguration);
      if ((localConfiguration != null) && (localConfiguration.locale != null))
      {
        localJSONObject.put("locale", localConfiguration.locale.getDisplayName());
        Calendar localCalendar = Calendar.getInstance(localConfiguration.locale);
        if (localCalendar == null)
          break label539;
        TimeZone localTimeZone = localCalendar.getTimeZone();
        if (localTimeZone == null)
          break label527;
        localJSONObject.put("timezone", localTimeZone.getRawOffset() / 3600000);
        label527: label539: label567: localJSONObject.put("resolution", h.k(this.mContext));
      }
    }
    catch (Exception localException1)
    {
      try
      {
        while (true)
        {
          while (true)
          {
            String[] arrayOfString = h.l(this.mContext);
            localJSONObject.put("access", arrayOfString[0]);
            if ("2G/3G".equals(arrayOfString[0]))
              localJSONObject.put("access_subtype", arrayOfString[1]);
            localJSONObject.put("carrier", h.j(this.mContext));
            double[] arrayOfDouble = h.m(this.mContext);
            localJSONObject.put("lat", String.valueOf(arrayOfDouble[0]));
            localJSONObject.put("lng", String.valueOf(arrayOfDouble[1]));
            localJSONObject.put("cpu", h.a());
            localJSONObject.put("time", new Date().toString());
            if ((this.a != null) && (!("".equals(this.a))))
              localJSONObject.put("keywords", this.a);
            if (this.autofill != 1)
              localJSONObject.put("autofill", this.autofill);
            if (this.require_desc != 1)
              localJSONObject.put("require_desc", this.require_desc);
            if ((ExchangeConstants.sid != null) && (!("".equals(ExchangeConstants.sid))) && (this.page_index > 1))
            {
              localJSONObject.put("sid", ExchangeConstants.sid);
              n.c(ExchangeConstants.LOG_TAG, "sid = " + ExchangeConstants.sid + "\tpage_index = " + this.page_index);
            }
            if (!(this.pagination))
              break label567;
            localJSONObject.put("more", 1);
            break label567:
            localJSONObject.put("locale", "null");
          }
          localException1 = localException1;
          localException1.printStackTrace();
          n.e(ExchangeConstants.LOG_TAG, "ERROR GET INPUT.");
          break label567:
          localJSONObject.put("timezone", 8);
        }
        localJSONObject.put("timezone", 8);
      }
      catch (Exception localException2)
      {
        while (true)
          localJSONObject.put("access", "Unknown");
        return localJSONObject;
      }
    }
  }

  private void a(List<com.exchange.b.a> paramList)
  {
    if (paramList == null)
      return;
    ArrayList localArrayList = new ArrayList();
    int i = paramList.size() - 1;
    while (true)
    {
      while (true)
      {
        do
          if (i >= 0)
            break label63;
        while (localArrayList.size() <= 0);
        new a(-1, this.mContext, localArrayList, -1, -1, -1, -1).start();
      }
      if (h.a(((com.exchange.b.a)paramList.get(i)).s, this.mContext))
      {
        label63: n.a(ExchangeConstants.LOG_TAG, "Installed: " + ((com.exchange.b.a)paramList.get(i)).g + ". Remove from the list.");
        localArrayList.add((com.exchange.b.a)paramList.remove(i));
      }
      --i;
    }
  }

  private void b(List<com.exchange.b.a> paramList)
  {
    int l;
    int i = 0;
    ArrayList localArrayList = new ArrayList();
    int j = 0;
    if ((j >= paramList.size()) || (i >= paramList.size()))
    {
      if (localArrayList.size() > 0)
        new a(-1, this.mContext, localArrayList, -1, -1, -1, -1).start();
      return;
    }
    int k = i + 1;
    if (h.a(((com.exchange.b.a)paramList.get(j)).s, this.mContext))
    {
      n.a(ExchangeConstants.LOG_TAG, "Installed: " + ((com.exchange.b.a)paramList.get(j)).g + ". Move to the end of the list.");
      com.exchange.b.a locala = (com.exchange.b.a)paramList.remove(j);
      paramList.add(locala);
      localArrayList.add(locala);
      l = j - 1;
    }
    while (true)
    {
      while (true)
      {
        j = l + 1;
        i = k;
      }
      l = j;
    }
  }

  public List<com.exchange.b.a> getExampleAds(int paramInt)
  {
    ArrayList localArrayList = new ArrayList();
    switch (paramInt)
    {
    default:
      return localArrayList;
    case 0:
      localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[0], ExchangeConstants.sample_des[0], ExchangeConstants.sample_detailDes[0], 160000L, "1.1", ExchangeConstants.sample_appIcon[0]));
      localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[1], ExchangeConstants.sample_des[1], ExchangeConstants.sample_detailDes[1], 160000L, "1.1", ExchangeConstants.sample_appIcon[1]));
      localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[2], ExchangeConstants.sample_des[2], ExchangeConstants.sample_detailDes[2], 160000L, "1.1", ExchangeConstants.sample_appIcon[2]));
      localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[3], ExchangeConstants.sample_des[3], ExchangeConstants.sample_detailDes[3], 160000L, "1.1", ExchangeConstants.sample_appIcon[3]));
      localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[4], ExchangeConstants.sample_des[4], ExchangeConstants.sample_detailDes[4], 160000L, "1.1", ExchangeConstants.sample_appIcon[4]));
      localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[5], ExchangeConstants.sample_des[5], ExchangeConstants.sample_detailDes[5], 160000L, "1.1", ExchangeConstants.sample_appIcon[5]));
      localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[6], ExchangeConstants.sample_des[6], ExchangeConstants.sample_detailDes[6], 160000L, "1.1", ExchangeConstants.sample_appIcon[6]));
      localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[7], ExchangeConstants.sample_des[7], ExchangeConstants.sample_detailDes[7], 160000L, "1.1", ExchangeConstants.sample_appIcon[7]));
      ((com.exchange.b.a)localArrayList.get(1)).m = 1;
      ((com.exchange.b.a)localArrayList.get(1)).e = "http://www.goapk.com/img/down.gif";
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    case 7:
    }
    try
    {
      ((com.exchange.b.a)localArrayList.get(1)).f = o.a(this.mContext, ((com.exchange.b.a)localArrayList.get(1)).e);
    }
    catch (Exception localException)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  while (true)
                    localException.printStackTrace();
                  localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[1], ExchangeConstants.sample_des[1], ExchangeConstants.sample_detailDes[1], 160000L, "1.1", ExchangeConstants.sample_appIcon[1]));
                  localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[2], ExchangeConstants.sample_des[2], ExchangeConstants.sample_detailDes[2], 160000L, "1.1", ExchangeConstants.sample_appIcon[2]));
                  localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[0], ExchangeConstants.sample_des[0], ExchangeConstants.sample_detailDes[0], 160000L, "1.1", ExchangeConstants.sample_appIcon[0]));
                  localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[7], ExchangeConstants.sample_des[7], ExchangeConstants.sample_detailDes[7], 160000L, "1.1", ExchangeConstants.sample_appIcon[7]));
                  localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[6], ExchangeConstants.sample_des[6], ExchangeConstants.sample_detailDes[6], 160000L, "1.1", ExchangeConstants.sample_appIcon[6]));
                  localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[5], ExchangeConstants.sample_des[5], ExchangeConstants.sample_detailDes[5], 160000L, "1.1", ExchangeConstants.sample_appIcon[5]));
                  localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[4], ExchangeConstants.sample_des[4], ExchangeConstants.sample_detailDes[4], 160000L, "1.1", ExchangeConstants.sample_appIcon[4]));
                  localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[3], ExchangeConstants.sample_des[3], ExchangeConstants.sample_detailDes[3], 160000L, "1.1", ExchangeConstants.sample_appIcon[3]));
                }
                localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[2], ExchangeConstants.sample_des[2], ExchangeConstants.sample_detailDes[2], 160000L, "1.1", ExchangeConstants.sample_appIcon[2]));
                localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[4], ExchangeConstants.sample_des[4], ExchangeConstants.sample_detailDes[4], 160000L, "1.1", ExchangeConstants.sample_appIcon[4]));
                localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[1], ExchangeConstants.sample_des[1], ExchangeConstants.sample_detailDes[1], 160000L, "1.1", ExchangeConstants.sample_appIcon[1]));
                localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[3], ExchangeConstants.sample_des[3], ExchangeConstants.sample_detailDes[3], 160000L, "1.1", ExchangeConstants.sample_appIcon[3]));
                localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[6], ExchangeConstants.sample_des[6], ExchangeConstants.sample_detailDes[6], 160000L, "1.1", ExchangeConstants.sample_appIcon[6]));
                localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[5], ExchangeConstants.sample_des[5], ExchangeConstants.sample_detailDes[5], 160000L, "1.1", ExchangeConstants.sample_appIcon[5]));
                localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[7], ExchangeConstants.sample_des[7], ExchangeConstants.sample_detailDes[7], 160000L, "1.1", ExchangeConstants.sample_appIcon[7]));
                localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[0], ExchangeConstants.sample_des[0], ExchangeConstants.sample_detailDes[0], 160000L, "1.1", ExchangeConstants.sample_appIcon[0]));
              }
              localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[3], ExchangeConstants.sample_des[3], ExchangeConstants.sample_detailDes[3], 160000L, "1.1", ExchangeConstants.sample_appIcon[3]));
              localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[1], ExchangeConstants.sample_des[1], ExchangeConstants.sample_detailDes[1], 160000L, "1.1", ExchangeConstants.sample_appIcon[1]));
              localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[0], ExchangeConstants.sample_des[0], ExchangeConstants.sample_detailDes[0], 160000L, "1.1", ExchangeConstants.sample_appIcon[0]));
              localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[5], ExchangeConstants.sample_des[5], ExchangeConstants.sample_detailDes[5], 160000L, "1.1", ExchangeConstants.sample_appIcon[5]));
              localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[4], ExchangeConstants.sample_des[4], ExchangeConstants.sample_detailDes[4], 160000L, "1.1", ExchangeConstants.sample_appIcon[4]));
              localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[2], ExchangeConstants.sample_des[2], ExchangeConstants.sample_detailDes[2], 160000L, "1.1", ExchangeConstants.sample_appIcon[2]));
              localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[6], ExchangeConstants.sample_des[6], ExchangeConstants.sample_detailDes[6], 160000L, "1.1", ExchangeConstants.sample_appIcon[6]));
              localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[7], ExchangeConstants.sample_des[7], ExchangeConstants.sample_detailDes[7], 160000L, "1.1", ExchangeConstants.sample_appIcon[7]));
            }
            localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[4], ExchangeConstants.sample_des[4], ExchangeConstants.sample_detailDes[4], 160000L, "1.1", ExchangeConstants.sample_appIcon[4]));
            localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[3], ExchangeConstants.sample_des[3], ExchangeConstants.sample_detailDes[3], 160000L, "1.1", ExchangeConstants.sample_appIcon[3]));
            localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[2], ExchangeConstants.sample_des[2], ExchangeConstants.sample_detailDes[2], 160000L, "1.1", ExchangeConstants.sample_appIcon[2]));
            localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[1], ExchangeConstants.sample_des[1], ExchangeConstants.sample_detailDes[1], 160000L, "1.1", ExchangeConstants.sample_appIcon[1]));
            localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[5], ExchangeConstants.sample_des[5], ExchangeConstants.sample_detailDes[5], 160000L, "1.1", ExchangeConstants.sample_appIcon[5]));
            localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[0], ExchangeConstants.sample_des[0], ExchangeConstants.sample_detailDes[0], 160000L, "1.1", ExchangeConstants.sample_appIcon[0]));
            localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[7], ExchangeConstants.sample_des[7], ExchangeConstants.sample_detailDes[7], 160000L, "1.1", ExchangeConstants.sample_appIcon[7]));
            localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[6], ExchangeConstants.sample_des[6], ExchangeConstants.sample_detailDes[6], 160000L, "1.1", ExchangeConstants.sample_appIcon[6]));
          }
          localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[5], ExchangeConstants.sample_des[5], ExchangeConstants.sample_detailDes[5], 160000L, "1.1", ExchangeConstants.sample_appIcon[5]));
          localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[3], ExchangeConstants.sample_des[3], ExchangeConstants.sample_detailDes[3], 160000L, "1.1", ExchangeConstants.sample_appIcon[3]));
          localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[2], ExchangeConstants.sample_des[2], ExchangeConstants.sample_detailDes[2], 160000L, "1.1", ExchangeConstants.sample_appIcon[2]));
          localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[1], ExchangeConstants.sample_des[1], ExchangeConstants.sample_detailDes[1], 160000L, "1.1", ExchangeConstants.sample_appIcon[1]));
          localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[0], ExchangeConstants.sample_des[0], ExchangeConstants.sample_detailDes[0], 160000L, "1.1", ExchangeConstants.sample_appIcon[0]));
          localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[6], ExchangeConstants.sample_des[6], ExchangeConstants.sample_detailDes[6], 160000L, "1.1", ExchangeConstants.sample_appIcon[6]));
          localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[7], ExchangeConstants.sample_des[7], ExchangeConstants.sample_detailDes[7], 160000L, "1.1", ExchangeConstants.sample_appIcon[7]));
          localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[4], ExchangeConstants.sample_des[4], ExchangeConstants.sample_detailDes[4], 160000L, "1.1", ExchangeConstants.sample_appIcon[4]));
        }
        localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[6], ExchangeConstants.sample_des[6], ExchangeConstants.sample_detailDes[6], 160000L, "1.1", ExchangeConstants.sample_appIcon[6]));
        localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[3], ExchangeConstants.sample_des[3], ExchangeConstants.sample_detailDes[3], 160000L, "1.1", ExchangeConstants.sample_appIcon[3]));
        localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[2], ExchangeConstants.sample_des[2], ExchangeConstants.sample_detailDes[2], 160000L, "1.1", ExchangeConstants.sample_appIcon[2]));
        localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[1], ExchangeConstants.sample_des[1], ExchangeConstants.sample_detailDes[1], 160000L, "1.1", ExchangeConstants.sample_appIcon[1]));
        localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[0], ExchangeConstants.sample_des[0], ExchangeConstants.sample_detailDes[0], 160000L, "1.1", ExchangeConstants.sample_appIcon[0]));
        localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[7], ExchangeConstants.sample_des[7], ExchangeConstants.sample_detailDes[7], 160000L, "1.1", ExchangeConstants.sample_appIcon[7]));
        localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[4], ExchangeConstants.sample_des[4], ExchangeConstants.sample_detailDes[4], 160000L, "1.1", ExchangeConstants.sample_appIcon[4]));
        localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[5], ExchangeConstants.sample_des[5], ExchangeConstants.sample_detailDes[5], 160000L, "1.1", ExchangeConstants.sample_appIcon[5]));
      }
      localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[7], ExchangeConstants.sample_des[7], ExchangeConstants.sample_detailDes[7], 160000L, "1.1", ExchangeConstants.sample_appIcon[7]));
      localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[3], ExchangeConstants.sample_des[3], ExchangeConstants.sample_detailDes[3], 160000L, "1.1", ExchangeConstants.sample_appIcon[3]));
      localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[4], ExchangeConstants.sample_des[4], ExchangeConstants.sample_detailDes[4], 160000L, "1.1", ExchangeConstants.sample_appIcon[4]));
      localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[2], ExchangeConstants.sample_des[2], ExchangeConstants.sample_detailDes[2], 160000L, "1.1", ExchangeConstants.sample_appIcon[2]));
      localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[1], ExchangeConstants.sample_des[1], ExchangeConstants.sample_detailDes[1], 160000L, "1.1", ExchangeConstants.sample_appIcon[1]));
      localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[0], ExchangeConstants.sample_des[0], ExchangeConstants.sample_detailDes[0], 160000L, "1.1", ExchangeConstants.sample_appIcon[0]));
      localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[5], ExchangeConstants.sample_des[5], ExchangeConstants.sample_detailDes[5], 160000L, "1.1", ExchangeConstants.sample_appIcon[5]));
      localArrayList.add(new com.exchange.b.a(ExchangeConstants.sample_title[6], ExchangeConstants.sample_des[6], ExchangeConstants.sample_detailDes[6], 160000L, "1.1", ExchangeConstants.sample_appIcon[6]));
    }
  }

  public void requestDataAsyn(Context paramContext, ExchangeDataRequestListener paramExchangeDataRequestListener)
  {
    this.d = "EXCHANGE_PRELOAD_ADS_" + this.a + "_" + this.autofill;
    this.mContext = paramContext;
    if ((ExchangeConstants.ONLY_CHINESE) && (!(h.a(this.mContext))))
    {
      n.b(ExchangeConstants.LOG_TAG, "English os can not show ads");
      paramExchangeDataRequestListener.dataReceived(0, null);
      if (this.mDataReceiverListener != null)
        this.mDataReceiverListener.dataReceived(0, null);
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          do
          {
            return;
            if (!(ExchangeConstants.isTestMode))
              break label137;
            paramExchangeDataRequestListener.dataReceived(1, getExampleAds(0));
          }
          while (this.mDataReceiverListener == null);
          this.mDataReceiverListener.dataReceived(1, getExampleAds(0));
        }
        label137: if (this.mContext.getSharedPreferences(this.d, 0).getInt("PRELOAD", 1) != 1)
          break;
        new a(this, new b(this, paramExchangeDataRequestListener), 1).start();
      }
      new a(this, paramExchangeDataRequestListener, 0).start();
    }
  }

  public void setKeywords(String paramString)
  {
    this.a = paramString;
  }

  class a extends Thread
  {
    private ExchangeDataRequestListener b;
    private int c;
    private Handler d;

    public a(, ExchangeDataRequestListener paramExchangeDataRequestListener, int paramInt)
    {
      this.d = new d(this);
      this.b = paramExchangeDataRequestListener;
      this.c = paramInt;
    }

    private ArrayList<com.exchange.b.a> a()
    {
      String str2;
      Object localObject;
      int i = 0;
      JSONObject localJSONObject1 = ExchangeDataService.a(this.a);
      if (localJSONObject1 == null)
      {
        localObject = null;
        return localObject;
      }
      String str1 = null;
      while (true)
      {
        if (i >= ExchangeConstants.REQUEST_URL_LIST.length)
          str2 = str1;
        while (true)
        {
          while (true)
          {
            if (str2 != null)
              break label73;
            localObject = null;
          }
          str1 = o.a(localJSONObject1.toString(), ExchangeConstants.REQUEST_URL_LIST[i]);
          if (str1 == null)
            break;
          str2 = str1;
        }
        ++i;
      }
      try
      {
        label73: JSONObject localJSONObject2 = new JSONObject(str2);
        ArrayList localArrayList = ExchangeDataService.a(this.a, localJSONObject2);
        if (localArrayList != null)
        {
          if (localArrayList.size() <= 0)
            break label231:
          SharedPreferences.Editor localEditor = this.a.mContext.getSharedPreferences(ExchangeDataService.b(this.a), 0).edit();
          localEditor.putString("PAGE_1", str2);
          localEditor.commit();
          Date localDate = new Date();
          h.a(this.a.mContext, localDate);
          n.c(ExchangeConstants.LOG_TAG, localDate.toString() + "\tWrite preload:\t" + str2);
          label231: localObject = localArrayList;
        }
      }
      catch (Exception localException)
      {
        while (true)
        {
          localException.printStackTrace();
          localObject = null;
        }
        localObject = null;
      }
    }

    private ArrayList<com.exchange.b.a> b()
    {
      ArrayList localArrayList;
      String str;
      try
      {
        str = this.a.mContext.getSharedPreferences(ExchangeDataService.b(this.a), 0).getString("PAGE_1", null);
        n.c(ExchangeConstants.LOG_TAG, h.h(this.a.mContext).toLocaleString() + "\tRead preload:\t" + str);
        if (str == null)
        {
          localArrayList = null;
        }
        else
        {
          JSONObject localJSONObject = new JSONObject(str);
          localArrayList = ExchangeDataService.a(this.a, localJSONObject);
          if (localArrayList != null)
          {
            int i = localArrayList.size();
            if (i > 0)
              break label124;
          }
          localArrayList = null;
        }
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
        localArrayList = null;
      }
      label124: return localArrayList;
    }

    public void run()
    {
      ArrayList localArrayList;
      if (this.c == 1)
        localArrayList = b();
      while (true)
      {
        Message localMessage = new Message();
        localMessage.obj = localArrayList;
        this.d.sendMessage(localMessage);
        return;
        localArrayList = a();
      }
    }
  }
}